#!/usr/bin/perl
################################################################################
#
# Runs the OSIS-to-Sword converter.
#
#   osis2Sword.pl <topLevelOutputFolder> <osisFile> <isoCode> <otherArgs>
#
# This merely passes the parameters on to the relevant platform-specific
# processing.  We assume that that will be happy with the arguments received
# by the present script.  See those scripts for details of the meaning of the
# arguments.
################################################################################

#-------------------------------------------------------------------------------
use strict;
use warnings;
use Cwd 'abs_path';
use File::Basename;
use File::Path;
use File::Spec;



#-------------------------------------------------------------------------------
my $scriptFolder = dirname(File::Spec->rel2abs( __FILE__ ));
require "$scriptFolder/jamieSharedFunctions.pl";



#-------------------------------------------------------------------------------
my ($outputFolder, $osisFile, $isoCode, @otherArgs) = @ARGV;
my $otherArgsAsString = join(" ", @otherArgs);
if ("null" eq $otherArgsAsString) { $otherArgsAsString = ""; }
my $operatingSystem = getOperatingSystem();



#-------------------------------------------------------------------------------
my $newScript = File::Spec->catfile(abs_path("$scriptFolder/Create_Sword_$operatingSystem/osis2Sword.pl"));
my $status = system("perl \"$newScript\" $outputFolder $osisFile $isoCode $otherArgsAsString");
if (0 != ($status >> 8)) { die "Conversion failed"; }

$newScript = File::Spec->catfile(abs_path("$scriptFolder/swordConfCreator.pl"));
my $s = File::Spec->catfile(abs_path("$outputFolder/mods.d"));
$status = system("perl \"$newScript\" $outputFolder $isoCode");
if (0 != ($status >> 8)) { die "Conversion failed"; }



#-------------------------------------------------------------------------------
print "Processing completed successfully";
